﻿Public Class frmStudentList
    Dim dbBase As New dbStudent
    Dim frmCtrl As New control
    Dim dsBase As DataSet
    Dim EntryID As String
    Public ModuleName As String

    Private Sub frmStudentList_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        frmCtrl.reDesign(Me)
        EntryID = ""
        UcGridFilter1.Enabled = True
        dsBase = dbBase.GetBaseList()
        UcHeader1.Iniliaze("LIST : Student", Me, Nothing, UcGridFilter1.getDataGridView(), "StudentID", True)
        UcGridFilter1.Initialize(dsBase.Tables(0), "StudentID", UcHeader1, Me, True)
        If (dsBase IsNot Nothing) Then

        End If
        If (ModuleName = "Finance") Then
            UcHeader1.ActionCtrl(False, True, False, False, False, False, False, False, False, True)
        End If
    End Sub

    Private Sub tsNew_Click(ByVal sender As Object) Handles UcHeader1.tsNewClick
        If (ModuleName = "Administration") Then
            Dim OpenForm As New frmStudentEntry
            OpenForm.EntryID = ""
            frmCtrl.OpenFormDetail(Me, OpenForm)
        ElseIf (ModuleName = "Finance") Then
            Dim OpenForm As New frmStudentBillManagement
            OpenForm.EntryID = ""
            frmCtrl.OpenFormDetail(Me, OpenForm)
        End If
    End Sub

    Private Sub GridCellEnter_Click(ByVal sender As ucGridFilter, KeyValue As String) Handles UcGridFilter1.GridCellEnter
        Dim dvFind As DataView = New DataView(dsBase.Tables(0))
        dvFind.RowFilter = "[StudentID] = '" & KeyValue & "'"
        EntryID = dvFind.Item(0).Row("StudentID").ToString()
    End Sub

    Private Sub GridDoubleClick_Click(ByVal sender As ucGridFilter) Handles UcGridFilter1.GridDoubleClick
        If (ModuleName = "Administration") Then
            Dim OpenForm As New frmStudentEntry
            OpenForm.EntryID = EntryID
            frmCtrl.OpenFormDetail(Me, OpenForm)
        ElseIf (ModuleName = "Finance") Then
            Dim OpenForm As New frmStudentBillManagement
            OpenForm.EntryID = EntryID
            frmCtrl.OpenFormDetail(Me, OpenForm)
        End If
    End Sub

    Private Sub tsView_Click(ByVal sender As Object) Handles UcHeader1.tsViewClick
        If (ModuleName = "Finance") Then
            Dim OpenForm As New frmStudentBillManagement
            OpenForm.EntryID = EntryID
            frmCtrl.OpenFormDetail(Me, OpenForm)
        End If
    End Sub

    Private Sub tsEdit_Click(ByVal sender As Object) Handles UcHeader1.tsEditClick
        If (ModuleName = "Administration") Then
            Dim OpenForm As New frmStudentEntry
            OpenForm.EntryID = EntryID
            frmCtrl.OpenFormDetail(Me, OpenForm)
        End If
    End Sub

    Private Sub tsPrint_Click(ByVal sender As Object) Handles UcHeader1.tsPrintClick
        frmViewReport.Initialize_rptMaster("MasterStudent", dsBase)
    End Sub

    Private Sub tsRefresh_Click(ByVal sender As Object) Handles UcHeader1.tsRefreshClick
        frmCtrl.openChild(New frmStudentList, Me.ParentForm)
    End Sub
End Class